#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <algorithm>

using namespace std;

int main() {
    int n, m, a, b;
    cin >> n >> m >> a >> b;

    long long ret = 0;
    for (long long x = 0; x <= min(n / 2, m); x++)
    {
        long long y = min(n - x * 2, (m - x) / 2);
        ret = max(ret, a * x + b * y);
    }
    cout << ret << endl;
    return 0;
}